package svc

import (
	"bw-renting/api/internal/config"
	"bw-renting/api/internal/middleware"
	"bw-renting/house-rpc/houseclient"
	"bw-renting/order-rpc/order"
	"bw-renting/order-rpc/orderclient"
	"bw-renting/user-rpc/userclient"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config      config.Config
	AuthToken   rest.Middleware
	HouseServer houseclient.House
	UserServer  userclient.User
	OrderServer order.OrderClient
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:      c,
		AuthToken:   middleware.NewAuthTokenMiddleware().Handle,
		HouseServer: houseclient.NewHouse(zrpc.MustNewClient(c.HouseServer)),
		UserServer:  userclient.NewUser(zrpc.MustNewClient(c.UserServer)),
		OrderServer: orderclient.NewOrder(zrpc.MustNewClient(c.OrderServer)),
	}
}
